{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# Ames房价预测案例"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 导入必要的工具包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "from sklearn.metrics import r2_score\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "\n",
    "from IPython.display import display\n",
    "# 自定义\n",
    "pd.set_option('display.float_format', lambda x: '%.3f' % x)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 读入数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>334</th>\n",
       "      <th>335</th>\n",
       "      <th>336</th>\n",
       "      <th>337</th>\n",
       "      <th>338</th>\n",
       "      <th>339</th>\n",
       "      <th>340</th>\n",
       "      <th>341</th>\n",
       "      <th>342</th>\n",
       "      <th>SalePrice</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.227</td>\n",
       "      <td>-0.203</td>\n",
       "      <td>0.064</td>\n",
       "      <td>-0.243</td>\n",
       "      <td>0.701</td>\n",
       "      <td>0.026</td>\n",
       "      <td>0.226</td>\n",
       "      <td>1.253</td>\n",
       "      <td>-0.419</td>\n",
       "      <td>1.054</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>208500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.670</td>\n",
       "      <td>-0.086</td>\n",
       "      <td>0.064</td>\n",
       "      <td>-0.243</td>\n",
       "      <td>0.701</td>\n",
       "      <td>0.026</td>\n",
       "      <td>0.226</td>\n",
       "      <td>-0.694</td>\n",
       "      <td>1.858</td>\n",
       "      <td>0.159</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>181500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.316</td>\n",
       "      <td>0.081</td>\n",
       "      <td>0.064</td>\n",
       "      <td>-0.243</td>\n",
       "      <td>-1.029</td>\n",
       "      <td>0.026</td>\n",
       "      <td>0.226</td>\n",
       "      <td>1.253</td>\n",
       "      <td>-0.419</td>\n",
       "      <td>0.988</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>223500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.080</td>\n",
       "      <td>-0.091</td>\n",
       "      <td>0.064</td>\n",
       "      <td>-0.243</td>\n",
       "      <td>-1.029</td>\n",
       "      <td>0.026</td>\n",
       "      <td>0.226</td>\n",
       "      <td>1.253</td>\n",
       "      <td>-0.419</td>\n",
       "      <td>-1.861</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>140000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.789</td>\n",
       "      <td>0.387</td>\n",
       "      <td>0.064</td>\n",
       "      <td>-0.243</td>\n",
       "      <td>-1.029</td>\n",
       "      <td>0.026</td>\n",
       "      <td>0.226</td>\n",
       "      <td>1.253</td>\n",
       "      <td>-0.419</td>\n",
       "      <td>0.954</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>250000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 344 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      0      1     2      3      4     5     6      7      8      9  \\\n",
       "0 0.227 -0.203 0.064 -0.243  0.701 0.026 0.226  1.253 -0.419  1.054   \n",
       "1 0.670 -0.086 0.064 -0.243  0.701 0.026 0.226 -0.694  1.858  0.159   \n",
       "2 0.316  0.081 0.064 -0.243 -1.029 0.026 0.226  1.253 -0.419  0.988   \n",
       "3 0.080 -0.091 0.064 -0.243 -1.029 0.026 0.226  1.253 -0.419 -1.861   \n",
       "4 0.789  0.387 0.064 -0.243 -1.029 0.026 0.226  1.253 -0.419  0.954   \n",
       "\n",
       "     ...      334  335  336  337  338  339  340  341  342  SalePrice  \n",
       "0    ...        1    1    1    1    1    1    1    1    1     208500  \n",
       "1    ...        1    1    1    1    1    1    1    1    1     181500  \n",
       "2    ...        1    1    1    1    1    1    1    1    1     223500  \n",
       "3    ...        1    1    1    1    1    1    1    1    1     140000  \n",
       "4    ...        1    1    1    1    1    1    1    1    1     250000  \n",
       "\n",
       "[5 rows x 344 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 本项目中使用老师提供的特征工程后的数据集\n",
    "dpath = \"/Users/qi/PycharmProjects/HousePrices/\"\n",
    "data = pd.read_csv(dpath + \"AmesHouse_FE_train.csv\")\n",
    "\n",
    "# 通过观察前5行，了解数据每列（特征）的概况\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据基本信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1456, 344)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>334</th>\n",
       "      <th>335</th>\n",
       "      <th>336</th>\n",
       "      <th>337</th>\n",
       "      <th>338</th>\n",
       "      <th>339</th>\n",
       "      <th>340</th>\n",
       "      <th>341</th>\n",
       "      <th>342</th>\n",
       "      <th>SalePrice</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>...</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "      <td>1456.000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>0.000</td>\n",
       "      <td>-0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>-0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>-0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>-0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>180151.234</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>76696.593</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>-1.692</td>\n",
       "      <td>-0.928</td>\n",
       "      <td>-15.546</td>\n",
       "      <td>-0.243</td>\n",
       "      <td>-4.487</td>\n",
       "      <td>-38.144</td>\n",
       "      <td>-7.007</td>\n",
       "      <td>-2.641</td>\n",
       "      <td>-2.697</td>\n",
       "      <td>-3.285</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>34900.000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>-0.452</td>\n",
       "      <td>-0.295</td>\n",
       "      <td>0.064</td>\n",
       "      <td>-0.243</td>\n",
       "      <td>-1.029</td>\n",
       "      <td>0.026</td>\n",
       "      <td>0.226</td>\n",
       "      <td>-0.694</td>\n",
       "      <td>-0.419</td>\n",
       "      <td>-0.569</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>129900.000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>0.168</td>\n",
       "      <td>-0.099</td>\n",
       "      <td>0.064</td>\n",
       "      <td>-0.243</td>\n",
       "      <td>0.701</td>\n",
       "      <td>0.026</td>\n",
       "      <td>0.226</td>\n",
       "      <td>-0.694</td>\n",
       "      <td>-0.419</td>\n",
       "      <td>0.027</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>163000.000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>0.641</td>\n",
       "      <td>0.116</td>\n",
       "      <td>0.064</td>\n",
       "      <td>-0.243</td>\n",
       "      <td>0.701</td>\n",
       "      <td>0.026</td>\n",
       "      <td>0.226</td>\n",
       "      <td>1.253</td>\n",
       "      <td>-0.419</td>\n",
       "      <td>0.954</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>214000.000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>7.550</td>\n",
       "      <td>20.776</td>\n",
       "      <td>0.064</td>\n",
       "      <td>5.126</td>\n",
       "      <td>0.701</td>\n",
       "      <td>0.026</td>\n",
       "      <td>0.226</td>\n",
       "      <td>1.253</td>\n",
       "      <td>1.858</td>\n",
       "      <td>1.286</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>1.000</td>\n",
       "      <td>625000.000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8 rows × 344 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             0        1        2        3        4        5        6        7  \\\n",
       "count 1456.000 1456.000 1456.000 1456.000 1456.000 1456.000 1456.000 1456.000   \n",
       "mean     0.000   -0.000    0.000    0.000   -0.000    0.000   -0.000    0.000   \n",
       "std      1.000    1.000    1.000    1.000    1.000    1.000    1.000    1.000   \n",
       "min     -1.692   -0.928  -15.546   -0.243   -4.487  -38.144   -7.007   -2.641   \n",
       "25%     -0.452   -0.295    0.064   -0.243   -1.029    0.026    0.226   -0.694   \n",
       "50%      0.168   -0.099    0.064   -0.243    0.701    0.026    0.226   -0.694   \n",
       "75%      0.641    0.116    0.064   -0.243    0.701    0.026    0.226    1.253   \n",
       "max      7.550   20.776    0.064    5.126    0.701    0.026    0.226    1.253   \n",
       "\n",
       "             8        9    ...          334      335      336      337  \\\n",
       "count 1456.000 1456.000    ...     1456.000 1456.000 1456.000 1456.000   \n",
       "mean    -0.000    0.000    ...        1.000    1.000    1.000    1.000   \n",
       "std      1.000    1.000    ...        0.000    0.000    0.000    0.000   \n",
       "min     -2.697   -3.285    ...        1.000    1.000    1.000    1.000   \n",
       "25%     -0.419   -0.569    ...        1.000    1.000    1.000    1.000   \n",
       "50%     -0.419    0.027    ...        1.000    1.000    1.000    1.000   \n",
       "75%     -0.419    0.954    ...        1.000    1.000    1.000    1.000   \n",
       "max      1.858    1.286    ...        1.000    1.000    1.000    1.000   \n",
       "\n",
       "           338      339      340      341      342  SalePrice  \n",
       "count 1456.000 1456.000 1456.000 1456.000 1456.000   1456.000  \n",
       "mean     1.000    1.000    1.000    1.000    1.000 180151.234  \n",
       "std      0.000    0.000    0.000    0.000    0.000  76696.593  \n",
       "min      1.000    1.000    1.000    1.000    1.000  34900.000  \n",
       "25%      1.000    1.000    1.000    1.000    1.000 129900.000  \n",
       "50%      1.000    1.000    1.000    1.000    1.000 163000.000  \n",
       "75%      1.000    1.000    1.000    1.000    1.000 214000.000  \n",
       "max      1.000    1.000    1.000    1.000    1.000 625000.000  \n",
       "\n",
       "[8 rows x 344 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 各特征的统计信息（样本数，均值，标准差，最小值，1/4分位数，1/2分位数，3/4分位数，最大值）\n",
    "data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 从原始数据中分离输入特征X和输出y\n",
    "y = data['SalePrice'].values\n",
    "X = data.drop('SalePrice', axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/qi/anaconda3/lib/python3.6/site-packages/sklearn/cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.\n",
      "  \"This module will be removed in 0.20.\", DeprecationWarning)\n"
     ]
    }
   ],
   "source": [
    "# 将数据分割训练数据与测试数据\n",
    "from sklearn.cross_validation import train_test_split\n",
    "\n",
    "# 随机采样20%的数据构建测试样本，其余作为训练样本\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=33, test_size=0.2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据标准化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "# 初始化对目标值的标准化器\n",
    "ss_y = StandardScaler()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/qi/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n"
     ]
    }
   ],
   "source": [
    "# 对目标值进行归一化处理\n",
    "y_train = ss_y.fit_transform(y_train.reshape(-1, 1))\n",
    "y_test = ss_y.transform(y_test.reshape(-1, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 179985.62371134])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ss_y.mean_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([  5.97127597e+09])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ss_y.var_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.67274377],\n",
       "       [-0.12922354],\n",
       "       [-0.57568659],\n",
       "       ..., \n",
       "       [-0.62745042],\n",
       "       [ 0.45311957],\n",
       "       [ 4.87350496]])"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_train"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 尝试缺省参数的线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 预测，下面score会自动调用predict\n",
    "lr_y_predict = lr.predict(X_test)\n",
    "lr_y_predict_train = lr.predict(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  1.31022787e-02,   7.05218188e-02,   2.46477184e-02,\n",
       "         -5.92060367e-04,   3.35323689e-03,   1.35585395e-02,\n",
       "          1.19704568e-02,   4.21257509e+05,  -4.66400172e-02,\n",
       "          1.94358618e-01,   3.03268133e-02,   2.60938218e-02,\n",
       "         -3.38906254e+05,  -3.11994141e-02,  -9.82859111e-03,\n",
       "          5.27360372e-03,   6.81514594e-02,   1.01155703e-02,\n",
       "          5.41536330e+09,   8.14978281e-03,   2.03298565e+09,\n",
       "          5.56567175e+09,   7.45519666e+08,   1.60583826e-02,\n",
       "          1.89622486e+09,   2.21570436e+09,   4.04431174e+08,\n",
       "          3.02500882e+09,   1.11221198e+09,   2.55564007e+08,\n",
       "          1.17726293e+09,   5.40105478e+08,  -4.29420622e-02,\n",
       "         -4.37893736e-02,  -5.20958460e-02,   4.25818935e-02,\n",
       "          5.09619129e-02,  -4.15737589e+05,  -5.28610391e-03,\n",
       "          4.43822706e-03,  -1.12619578e+05,  -7.63207022e+00,\n",
       "         -1.98827770e-03,   1.61647423e-01,  -6.43410683e-03,\n",
       "          2.35406550e-02,  -2.79873495e+09,  -2.62057429e+09,\n",
       "         -1.25722372e+09,  -2.39086630e+09,  -5.18646077e-03,\n",
       "         -1.97419454e-01,   8.49212994e-02,   3.25292886e-03,\n",
       "          1.46769923e-01,  -1.59421590e-01,   2.02514673e-02,\n",
       "          7.36815967e-02,   4.15737620e+05,   2.99950969e-01,\n",
       "          2.29331723e-01,  -1.67264111e+09,  -1.09478795e+10,\n",
       "          1.56097477e+09,   4.49064551e+09,   8.95311051e+04,\n",
       "          5.79477086e+04,  -5.41372442e+00,   2.74092912e+00,\n",
       "         -1.65820408e+00,   1.81425288e+01,  -6.21099565e+00,\n",
       "          1.11451439e+01,  -1.64720832e+01,   5.58611723e+00,\n",
       "         -1.07583904e+01,  -6.78065670e+05,   3.72452328e+05,\n",
       "         -1.14580555e+05,   5.70748935e+04,  -1.52829475e+04,\n",
       "          9.01515434e+04,   1.02458644e+00,  -5.00028929e-01,\n",
       "          1.47430648e-01,   4.67551225e+00,  -1.49785371e+00,\n",
       "          5.20592035e+00,   1.46274345e+00,  -3.84672345e-01,\n",
       "          1.21934190e+00,   2.17086974e+05,   7.75674837e+03,\n",
       "          1.14062521e+05,   5.89769904e+00,  -2.30580842e+00,\n",
       "          3.80327471e+00,  -1.48621240e+04,   1.13973637e+04,\n",
       "         -1.02958985e+05,  -1.48620877e+04,  -1.48620202e+04,\n",
       "         -7.87400436e+04,   6.80236136e+04,   6.80236437e+04,\n",
       "         -9.45541002e+03,  -5.70007058e+04,  -5.70007335e+04,\n",
       "         -5.70005961e+04,  -5.70007485e+04,  -5.70007160e+04,\n",
       "         -5.70008445e+04,  -5.70006441e+04,  -5.70005615e+04,\n",
       "         -5.70004315e+04,   2.16740432e+05,  -6.14092947e+04,\n",
       "         -6.14092341e+04,  -6.14091281e+04,  -6.70509958e+04,\n",
       "         -6.14092709e+04,  -1.03604762e+05,  -1.40199572e+05,\n",
       "         -6.14091489e+04,  -1.53109712e+05,   2.60326194e+04,\n",
       "          2.60326285e+04,   2.60326243e+04,   2.60327141e+04,\n",
       "          2.60326001e+04,   2.60325147e+04,   7.67220243e+03,\n",
       "          7.67205012e+03,   7.67194190e+03,   7.67238698e+03,\n",
       "          8.13148681e+03,   7.67189165e+03,   7.67209373e+03,\n",
       "          7.67215885e+03,   7.67219875e+03,   7.67214603e+03,\n",
       "          7.67303058e+03,   7.67240057e+03,   7.67208568e+03,\n",
       "          7.67205353e+03,   7.67226919e+03,  -1.60628942e+05,\n",
       "         -1.16182176e+04,  -1.16182867e+04,  -1.16179272e+04,\n",
       "         -1.16182396e+04,  -1.20775739e+04,  -1.16177573e+04,\n",
       "         -1.16181407e+04,  -1.16180816e+04,  -1.16181482e+04,\n",
       "         -1.16185798e+04,  -1.16181961e+04,  -1.16184766e+04,\n",
       "         -1.16182473e+04,  -1.16180789e+04,  -1.16180352e+04,\n",
       "         -1.16182021e+04,   7.09132507e+04,  -5.53798517e+03,\n",
       "         -5.53796801e+03,  -5.53794283e+03,  -5.53804156e+03,\n",
       "         -5.53794136e+03,  -6.08744818e+03,  -3.00403638e+04,\n",
       "         -3.00403806e+04,  -3.00403280e+04,  -3.00404229e+04,\n",
       "         -3.00405669e+04,  -3.00409293e+04,   2.87143358e+04,\n",
       "          1.66577334e+05,   5.69021732e+04,   1.66577306e+05,\n",
       "          1.66577321e+05,   6.76296268e+04,  -1.26770777e+05,\n",
       "         -1.26770539e+05,  -1.26770493e+05,  -1.26770474e+05,\n",
       "         -1.26770377e+05,  -1.26770517e+05,   8.67426084e+04,\n",
       "         -3.92893722e+04,   4.72890478e+03,   2.74733421e+04,\n",
       "          2.74731848e+04,   2.74732341e+04,   2.74732852e+04,\n",
       "          2.74734346e+04,   1.09324709e+04,  -3.60983424e+04,\n",
       "         -3.60979218e+04,  -3.60982953e+04,  -3.60981675e+04,\n",
       "         -3.60980690e+04,  -3.60982244e+04,  -3.60982331e+04,\n",
       "         -3.60980867e+04,   2.50676624e+04,   8.02869590e+04,\n",
       "          8.02870135e+04,   8.02868492e+04,   8.02869315e+04,\n",
       "         -1.94425835e+04,   5.06911354e+04,   5.06912123e+04,\n",
       "          5.06910418e+04,   5.06909210e+04,   5.06910973e+04,\n",
       "         -7.38641135e+03,  -9.30265687e+03,   9.27338213e+03,\n",
       "         -9.30282115e+03,  -9.30290614e+03,  -3.55619789e+04,\n",
       "         -9.30237087e+03,  -9.30245349e+03,  -9.30231929e+03,\n",
       "         -9.30280058e+03,  -9.30222343e+03,  -9.30233402e+03,\n",
       "         -9.30223638e+03,  -9.30238869e+03,  -9.30260741e+03,\n",
       "         -9.30254013e+03,   7.87942513e+04,   1.32330747e+04,\n",
       "         -1.06797593e+05,  -1.06796908e+05,  -1.06797235e+05,\n",
       "         -1.06797141e+05,  -1.06797208e+05,  -5.46162944e+04,\n",
       "         -9.96549705e+04,  -9.96548133e+04,   8.29651720e+04,\n",
       "         -9.96547073e+04,   2.30746219e+03,   3.64728261e+03,\n",
       "         -3.85461151e+04,  -3.85461874e+04,  -3.85462078e+04,\n",
       "         -3.85472019e+04,  -7.62681156e+03,  -2.57349161e+04,\n",
       "         -2.57349447e+04,  -2.57349076e+04,  -2.57350086e+04,\n",
       "         -2.57349231e+04,  -2.57349420e+04,  -2.57349404e+04,\n",
       "         -2.57349338e+04,  -2.57348966e+04,  -2.57349311e+04,\n",
       "         -2.57349684e+04,  -2.57348825e+04,   0.00000000e+00,\n",
       "          1.53776102e+04,   1.53780095e+04,   1.53778895e+04,\n",
       "          1.53778347e+04,   1.53776809e+04,   1.53776003e+04,\n",
       "          1.53780112e+04,   1.53775768e+04,   1.53775545e+04,\n",
       "          1.53777050e+04,   1.53775270e+04,   1.53775519e+04,\n",
       "          1.53776207e+04,   1.53778589e+04,   1.53776237e+04,\n",
       "          1.53777573e+04,   1.53780419e+04,   1.53776445e+04,\n",
       "          1.53777051e+04,   1.53776801e+04,   1.53776565e+04,\n",
       "          1.53776198e+04,   1.53782394e+04,   1.53776521e+04,\n",
       "          1.53779477e+04,   0.00000000e+00,  -1.37151613e+04,\n",
       "         -1.37143856e+04,  -1.37148469e+04,  -1.37151023e+04,\n",
       "         -1.37151358e+04,  -1.37150801e+04,  -1.37148856e+04,\n",
       "          0.00000000e+00,   9.10448955e+04,   9.10449804e+04,\n",
       "          9.10450775e+04,   9.10450325e+04,   9.10452209e+04,\n",
       "          9.10455229e+04,   0.00000000e+00,   5.24290449e+04,\n",
       "          5.24291560e+04,   5.24290305e+04,   5.24289979e+04,\n",
       "          5.24291399e+04,  -1.55938574e+05,   0.00000000e+00,\n",
       "          3.14053906e+04,   3.14057795e+04,   3.14056504e+04,\n",
       "          3.14056340e+04,   3.14055002e+04,   3.14054435e+04,\n",
       "          3.14057050e+04,   3.14051024e+04,   3.14053544e+04,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00]])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 显示特征的回归系数\n",
    "lr.coef_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "观察到有些回归系数非常大"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the value of default measurement of LinearRegression on test is:  -34262229.1416\n",
      "The value of default measurement of LinearRegression on train is 0.940369426882\n"
     ]
    }
   ],
   "source": [
    "# 使用LinearRegression模型自带的评估模块（r2_score），并输出评估结果\n",
    "\n",
    "# 测试集\n",
    "print('the value of default measurement of LinearRegression on test is: ', lr.score(X_test, y_test))\n",
    "\n",
    "# 训练集\n",
    "print('The value of default measurement of LinearRegression on train is', lr.score(X_train, y_train))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "测试集上表现很不好。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x1a0d9f2b70>"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAe8AAAFsCAYAAADlrTG7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xu4XHV97/H31xCIJRAu2cGQYBMQ\nVK5JzgZJqRgbERQl2laFg1wqEETpY7XHo+hRdqme2gPqI0ekReUmCAEshR7xFExBLkfAHRoDGGgC\nQklIk02o3G8J3/PHrJ1Mkr2zJ3tmX37Z79fzzDMzv3X7zm8m+ez1W2vWRGYiSZLK8YahLkCSJG0Z\nw1uSpMIY3pIkFcbwliSpMIa3JEmFMbwlSSqM4S31IiIejIhZQ13HUIqID0fEExHxfERMH8TtPh8R\ne/Yy7eSIuLNF23ksIt7TinVJg8nw1ojU03/aG4dCZu6Xmbf1sZ4pEZERsc0AlTrUzgPOzMyxmfmv\nG0+sXvsLVdguj4hvRcSoZjdabe/RZtcjba0Mb2kYGwZ/FPw+8GAf8xyUmWOBdwEfAz4x4FVJI5zh\nLfWifu88Ig6JiM6IeDYiVkbEt6rZbq/uf1ftfc6MiDdExP+IiMcjYlVEXB4R4+rWe2I1bXVEfGWj\n7XRExHURcUVEPAucXG37lxHxu4hYERHfjYht69aXEfGpiFgSEc9FxF9HxF7VMs9GxDX182/0Gnus\nNSK2i4jngVHAryPikb76KzOXAncB0+r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N77xjSxcuJAHHniAXXbZhQsuuKBf6/nBD36wSXAPB+3t7QMe3GvXrm3ZuhoO74gY\nC/wE+IvMfHZzs/bQtslPl2XmRZnZnpntbW19XsZVkjRMzJw5k+XLl697fu6553LwwQdz4IEHcvbZ\nZwPwwgsvcPTRR3PQQQex//77M2/ePKC219t9OexLLrmEffbZh3e9613cdddd69Z38sknc9111617\nPnbsWACef/55Zs+ezYwZMzjggAO44YYbNqltxYoVHH744UybNo3999+fO+64o6HXdNttt/GBD3wA\ngI6ODj7xiU8wa9Ys9txzzw1C/YorruCQQw5h2rRpnH766esC+YwzzqC9vZ399ttvXR9A7fLf55xz\nDn/4h3/Itdde21AtjWjoq2IRMZpacF+Zmf9QNa/sHg6PiInAqqp9GbBH3eKTqf1usSSpcGvXrmX+\n/PmccsopANx8880sWbKEe++9l8zkmGOO4fbbb6erq4vdd9+dn/70pwA888wzG6xnxYoVnH322SxY\nsIBx48bx7ne/m+nTp29222PGjOH6669nxx135KmnnuLQQw/lmGOO2eDkrx//+McceeSRfPnLX2bt\n2rW8+OKL/XqdDz30ELfeeivPPfccb33rWznjjDNYunQp8+bN46677mL06NF86lOf4sorr+TEE0/k\n61//Orvssgtr165l9uzZLFq0iAMPPHBd3XfeeWe/6uhNI2ebB/BDYHFmfqtu0o3ASdXjk4Ab6tpP\nrM46PxR4xuPdklS2l156iWnTprHrrrvy9NNPc8QRRwC18L755puZPn06M2bM4KGHHmLJkiUccMAB\n/PznP+cLX/gCd9xxB+PGjdtgfffccw+zZs2ira2Nbbfdlo997GN91pCZfOlLX+LAAw/kPe95D8uX\nL2flypUbzHPwwQdzySWX0NHRwf33388OO+zQr9d79NFHs9122zF+/HgmTJjAypUrmT9/PgsWLODg\ngw9m2rRpzJ8/n0cffRSAa665hhkzZjB9+nQefPBBfvOb36xbVyOvbUs1Mmx+GHAC8EcRsbC6vR/4\nBnBERCwBjqieA9wEPAosBb4PfKrlVUuSBlX3Me/HH3+cV199dd0x78zkrLPOYuHChSxcuJClS5dy\nyimnsM8++7BgwQIOOOAAzjrrLM4555xN1tnb16W22WYbXn/99XXrf/XVVwG48sor6erqYsGCBSxc\nuJDddtttk+9KH3744dx+++1MmjSJE044gcsvv7xfr3e77bZb93jUqFGsWbOGzOSkk05a91offvhh\nOjo6+O1vf8t5553H/PnzWbRoEUcfffQGdW2//fb9qmFzGjnb/E56Po4NMLuH+RP4dJN1SRqmtuRM\n51afFa2hN27cOM4//3zmzJnDGWecwZFHHslXvvIVjj/+eMaOHcvy5csZPXo0a9asYZddduHjH/84\nY8eO5dJLL91gPe94xzv4zGc+w+rVq9lxxx259tprOeigg4DaceIFCxbw0Y9+lBtuuIHXXnsNqA29\nT5gwgdGjR3Prrbfy+OOb/nrm448/zqRJkzjttNN44YUXuO+++zjxxBNb8tpnz57NnDlz+OxnP8uE\nCRN4+umnee6553j22WfZfvvtGTduHCtXruRnP/sZs2bNask2e+PlUSWpMEP9R9H06dM56KCDuPrq\nqznhhBNYvHgxM2fOBGonl11xxRUsXbqUz3/+87zhDW9g9OjRXHjhhpf8mDhxIh0dHcycOZOJEycy\nY8aMdSd/nXbaacyZM4dDDjmE2bNnr9tzPf744/ngBz9Ie3s706ZN421ve9smtd12222ce+65jB49\nmrFjx/a653300Uevu674zJkz+fSn+97n3Hffffna177Ge9/7Xl5//XVGjx7NBRdcwKGHHsr06dPZ\nb7/92HPPPTnssMMa78x+itqO8tBqb2/P7rMPJQ1v7nkPvsWLF/P2t799qMtQi/X0vkbEgsxs72WR\ndby2uSRJhTG8JUkqjOEtSQUYDoc41TrNvp+esCYJ8Pj0cDZmzBhWr17tz4JuJbp/z3vMmDH9Xofh\nLUnD3OTJk1m2bBn+DsTWY8yYMUyePLnfyxvekjTMjR49mqlTpw51GRpGPOYtSVJhDG9JkgpjeEuS\nVBjDW5KkwhjekiQVxvCWJKkwhrckSYUxvCVJKozhLUlSYQxvSZIKY3hLklQYw1uSpMIY3pIkFcbw\nliSpMIa3JEmFMbwlSSqM4S1JUmEMb0mS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1CXii7vmyqm1rs1tmrgCo7if0Mt+YiOiMiLsjYmsK+Ebe53XzZOYa4Blg10GpbnA1+pn/\nk2qo+LqI2KOH6SPBSPn/oVEzI+LXEfGziNivVSsdsJ8EHW4i4ufAm3qY9OXMvKHB1RyWmU9GxATg\nloh4qPrLqygt6Is+L39bis31xRas5s3V52JP4F8i4v7MfKQ1FQ6pRt7nreaz0IdGXuc/AVdl5isR\n8UlqIxJ/NOCVDT8j5TPRiPuoXav8+Yh4P/CP1A4nNG3EhHdmvqcF63iyul8VEddTG0orLrxb0Bdb\nzeVvN9cXEbEyIiZm5opq2G9VL+vo/lw8GhG3AdOBrSG8G3mfu+dZFhHbAOMYomHEAdZnX2Tm6rqn\n32crPf7fgK3m/4dmZeazdY9viojvRcT4zGz6x1scNm9QRGwfETt0PwbeS+3krpFopFz+9kbgpOrx\nScAmoxIRsXNEbFc9Hg8cBgza79YPsEbe5/o++lPgX3LrvPJTn32x0XHdY4DFg1jfcHIjcGJ11vmh\nwDPdh59Gmoh4U/c5IBFxCLXMXb35pRqUmSP+BnyY2l+LrwArgX+u2ncHbqoe7wn8uro9SG2Iechr\nH4q+qJ6/H/g3anuYW2tf7ErtLPMl1f0uVXs78IPq8R8A91efi/uBU4a67hb3wSbvM3AOcEz1eAxw\nLbAUuBfYc6hrHsK++Jvq/4ZfA7cCbxvqmgeoH64CVgCvVf9XnAJ8EvhkNT2onZn/SPVvon2oax7C\nvjiz7jNxN/AHrdq2l0eVJKnSeViEAAAALUlEQVQwDptLklQYw1uSpMIY3pIkFcbwliSpMIa3JEmF\nMbwlSSqM4S1JUmH+P7x+KcXdj5GIAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a0d9b6908>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 在训练集上查看模型预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5))\n",
    "f.tight_layout()\n",
    "ax.hist(y_train - lr_y_predict_train, bins=40, label='Residuals Linear', color='b', alpha=.5)\n",
    "ax.set_title('Histogram of Residuals')\n",
    "ax.legend(loc='best')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "残差分布和高斯分布比较匹配"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAHy1JREFUeJzt3Xt4VOW1+PHvmskkTLgFJKhEbqJC\nvZRbFBSs1WLVCojaeqn2eOw5rW210hsWaltsa48K2no51l+t1l9PpbW22lRQAVup9nJQwCBIgVbB\nKgEkQCKQBDJJ1vljJjQJM3v2npmdPUnW53nykJns7L24ZPFe1yuqijHG+CEUdADGmO7LEowxxjeW\nYIwxvrEEY4zxjSUYY4xvLMEYY3xjCcYY4xtLMMYY31iCMcb4piDoALwYNGiQjhgxIugwjOnx1qxZ\ns1tVS9Nd16USzIgRI1i9enXQYRjT44nIP91cZ10kY4xvLMEYY3zTpbpIxpjcq6isYuGyzWyvbWBI\nSZQ5F4xm1viynNzbEowxPVhFZRXznl5PQ6wZgKraBuY9vR4gJ0nGukjG9GALl20+nFxaNcSaWbhs\nc07ubwnGmB5se22Dp/e9sgRjTA82pCTq6X2vLMEY04PNuWA00Ui43XvRSJg5F4zOyf1tkNeYHqx1\nINdmkYwxvpg1vixnCaUj6yIZY3xjCcYY4xtLMMYY31iCMcb4xhKMMcY3lmCMMb6xBGOM8Y2tgzEm\nT/lZRqGzWIIxJg/5XUahs1gXyZg85HcZhc5iCcaYPOR3GYXOYgnGmDzkdxmFzmIJxpg85HcZhc5i\ng7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p8i8kSi\nbsrzieeuTdy3QER+mIhjnYh8IfH+6SLykoisEZHnReRon/4YTAYswRi3TgYeTWx6q3K47n5gQeIc\nnStIU6ZAREqJl5NoXVl8JvApVT2/w6WfB4YAYxM1eJ4QkSLi9UouV9WJwOPA97z9toyfbKuAcest\nVV3l4rppwOjE9gmAASISVdWGDtedKyKVxMsYfE9VN4vI2cByVa1Jcd97VbUZQFX3isg44BTg94nn\nhYlv0DN5whKMcauuzecttC8B0avN5wKckShs5WSFqs5K85y2hCNLTAiwTlXPTvMsExDrIhnPEgO8\nNSJyooiEgEvbfPn3wI2tLxKtjFxYDnw+Uf4TERlIfGdvmYickXivUEROydHzTA5YgjGZ+jqwFPgD\n7bslNwJTEgOxfwM+k6Pn/RjYCawTkdeBK1T1EPBx4AeJ9yqBSTl6nskBm6Y2xvjGWjDGGN9YgjHG\n+MYSjDHGN5ZgjDG+sQRjjPGNJRhjjG8swRhjfPN/Ozu5Zn5E604AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a19c6e5c0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_train, lr_y_predict_train)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True Price')\n",
    "plt.ylabel('Predicted Price')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAGtNJREFUeJzt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z\ngflAB3BzRCwuOKxqjgA+BiyS9MvU9sWIuK/AmNrBOcDt6T+YZaRJ4arxowJmlhufIplZbpxgzCw3\nTjBmlhsnGDPLjROMmeXGCcb6RdIukn6ZXn+QtKJseegA7ucDktam7T6Tfu1cadxeku4YqP1a//g2\ntQ0YSf8E/DkiruzVLrK/a9v9rI2kDwBnR8TM9PP/p4CPRMSvysYMKXtY1FqAj2AsF5L2Sc9Y/W/g\nF8BektaU9c+SdFN6v7ukuyU9IemxVAq4qoj4c9rmOyV9StK8NI/K/Wm/v0zbHSLpqhTHU5L+LrUf\nIulnkp6UdL+k3XP6Gt70nGAsTxOBuenBuBU1xl0LXJ5q7XyUOtMWSBpNNnVE6VfE7wE+FhEf7DX0\nTGAMcHCaY2eepGFkc5r8dUS8G/gucNG2fSxrlB8VsDz9v4h4vP4wPgDslx6PABglqSsi1vca935J\nC8mmNbgoIpZIOhJ4ICJWV9nu1RGxGbbUOH8XcADwk7S/DrKH+CwHTjCWp1fK3r9Bz+kedix7L2Bq\nmsSqlocjYmad/ZQTfaeTEPBURBxZZ182AHyKZE2RLvCuljRB0g7AR8q6fwKcVVpIRxkD4QHgzDTV\nJ5J2Jnv6d6ykqaltqKQDBmh/1osTjDXT+cCPgQfpeVpyFnBEuhD7NPDpAdrft4A/AE9J+hXw0Yh4\nHTgJ+EZqWwgcOkD7s158m9rMcuMjGDPLjROMmeXGCcbMcuMEY2a5cYIxs9w4wZhZbpxgzCw3/x9M\nKaeZXGm2LwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a19cfd240>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_test, lr_y_predict)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True Price')\n",
    "plt.ylabel('Predicted Price')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以看出，在个别点上预测残差很大，效果很不理想。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 线性模型，随机梯度下降优化模型参数\n",
    "from sklearn.linear_model import SGDRegressor\n",
    "\n",
    "# 使用默认配置初始化线\n",
    "sgdr = SGDRegressor(max_iter=5000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/qi/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py:578: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([ 0.01227622,  0.07508311,  0.02516649, -0.00299467,  0.00600289,\n",
       "        0.01460881,  0.01530947, -0.02286226, -0.05310027,  0.19910285,\n",
       "        0.02852501,  0.03141013, -0.00604922, -0.04094279, -0.01432677,\n",
       "        0.00393079,  0.07256503,  0.01428835, -0.05221302,  0.01563726,\n",
       "       -0.05342768, -0.14560773, -0.23166489,  0.01860233,  0.12432073,\n",
       "       -0.13236268, -0.01487865, -0.02401333, -0.00743616, -0.00174781,\n",
       "       -0.0021808 ,  0.02610863, -0.03584853, -0.06073341, -0.10523798,\n",
       "        0.03582054,  0.05363829,  0.02059618, -0.01368017,  0.00905734,\n",
       "       -0.06696119, -0.29731211,  0.04427436,  0.20920816, -0.00458893,\n",
       "        0.02033307,  0.01652722, -0.00666948,  0.01294595,  0.02588176,\n",
       "       -0.02343325, -0.26377624,  0.00508834,  0.00536404,  0.15919636,\n",
       "       -0.22415939,  0.04147974,  0.12141349,  0.02059618,  0.3562601 ,\n",
       "        0.30685069,  0.00168403, -0.14123499, -0.02277004,  0.02381244,\n",
       "       -0.00782006, -0.03520486, -0.12409537,  0.54579122,  0.33618798,\n",
       "       -0.01983481,  0.08298483,  0.02303195, -0.13477758,  0.06015004,\n",
       "        0.10343153, -0.01148295, -0.00453835, -0.03085185,  0.2715853 ,\n",
       "       -0.08111474, -0.08219057,  0.19365072, -0.10724009,  0.06077986,\n",
       "        0.22801254, -0.08517674, -0.23303474,  0.07627339,  0.01218494,\n",
       "       -0.04381227, -0.00604922, -0.00604922, -0.00604922,  0.42229223,\n",
       "       -0.43068476, -0.2067936 ,  0.08851071, -0.01910435, -0.03429412,\n",
       "       -0.04051893, -0.00758911,  0.        , -0.02824373,  0.01524794,\n",
       "        0.        , -0.03122733, -0.07383605,  0.05283215, -0.07244498,\n",
       "       -0.06504342, -0.19456842,  0.00924627,  0.1071983 ,  0.25484768,\n",
       "        0.        ,  0.04595981,  0.02445441,  0.09688441,  0.        ,\n",
       "       -0.06605216, -0.15950177,  0.        ,  0.0452595 ,  0.        ,\n",
       "       -0.00112643, -0.02551064,  0.01405791,  0.08626645, -0.03492877,\n",
       "       -0.05175431,  0.01346773, -0.02834493, -0.12549579,  0.18392814,\n",
       "       -0.03399488, -0.20773812, -0.051222  , -0.00650931,  0.02278165,\n",
       "       -0.00676401,  0.23274382,  0.17401824, -0.11566262, -0.14652058,\n",
       "        0.08231688,  0.        , -0.06018398, -0.06044969,  0.06550545,\n",
       "       -0.0783354 , -0.03399488,  0.34581192, -0.01121867,  0.07039874,\n",
       "       -0.0032944 , -0.20489494, -0.05815076, -0.13367078, -0.06880803,\n",
       "        0.10639327,  0.13132623, -0.01942989,  0.        ,  0.009082  ,\n",
       "       -0.01894341,  0.02960896, -0.06356726,  0.03082392,  0.        ,\n",
       "        0.10567524,  0.062384  ,  0.10851272,  0.11903956, -0.03716892,\n",
       "       -0.37143839,  0.        ,  0.06890881, -0.16321139,  0.02684427,\n",
       "        0.05446251,  0.        , -0.28048663,  0.05036829,  0.06506357,\n",
       "        0.10693635,  0.15043498,  0.05789904, -0.16321139,  0.        ,\n",
       "        0.        ,  0.05387809, -0.08044517, -0.01770862, -0.03864853,\n",
       "        0.06992844,  0.        , -0.13396947,  0.08567735, -0.09001573,\n",
       "       -0.22743191,  0.23816764,  0.06212493, -0.01627705,  0.06872845,\n",
       "        0.        ,  0.02021776,  0.08622795, -0.12025939,  0.00081789,\n",
       "        0.        ,  0.0429149 ,  0.13193326, -0.05182222, -0.15516584,\n",
       "        0.0191441 ,  0.        ,  0.00926832,  0.        , -0.22794761,\n",
       "       -0.18822176, -0.01910435,  0.10491768,  0.02907036,  0.1763871 ,\n",
       "       -0.10731143,  0.21906328,  0.05070478,  0.12156687, -0.00093038,\n",
       "       -0.06833623, -0.07782826, -0.03429412,  0.        , -0.39403311,\n",
       "        0.27879136,  0.03515489,  0.0706407 , -0.00354963,  0.        ,\n",
       "       -0.1320616 ,  0.00364971, -0.00394041,  0.11935651,  0.        ,\n",
       "       -0.15950177,  0.14757367,  0.10970795,  0.14591025, -0.25668589,\n",
       "        0.        ,  0.02670951, -0.01934327,  0.01185524, -0.06541927,\n",
       "        0.0248152 ,  0.00291737, -0.01095216, -0.02001433,  0.04184624,\n",
       "       -0.00964801, -0.03971349,  0.04395118,  0.        , -0.11485746,\n",
       "        0.19101609,  0.0380799 ,  0.08414702, -0.07341642, -0.12966198,\n",
       "        0.27382065, -0.15974317, -0.15446358, -0.02481302, -0.25885269,\n",
       "       -0.19316517, -0.117894  ,  0.17897715, -0.14113615,  0.02765642,\n",
       "        0.34702227, -0.07795492, -0.03399618, -0.07280565, -0.08005984,\n",
       "       -0.10118845,  0.49102474, -0.07676476,  0.16603341,  0.        ,\n",
       "       -0.20887313,  0.32339103,  0.0030934 , -0.13035114, -0.25952738,\n",
       "        0.01502896,  0.24424247,  0.        , -0.07111354, -0.08425574,\n",
       "        0.01660443, -0.01187488,  0.01213686,  0.12550708,  0.        ,\n",
       "       -0.02091616,  0.10830926, -0.09251864, -0.06629455,  0.06931274,\n",
       "       -0.01088845,  0.        , -0.150274  ,  0.27310503,  0.15399653,\n",
       "        0.15550131, -0.00682785, -0.12641423,  0.19169723, -0.32927332,\n",
       "       -0.17450649,  0.        , -0.01299579, -0.01299579, -0.01299579,\n",
       "       -0.01299579, -0.01299579, -0.01299579, -0.01299579, -0.01299579,\n",
       "       -0.01299579, -0.01299579, -0.01299579, -0.01299579, -0.01299579,\n",
       "       -0.01299579, -0.01299579, -0.01299579, -0.01299579, -0.01299579,\n",
       "       -0.01299579, -0.01299579, -0.01299579])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 训练：参数估计\n",
    "sgdr.fit(X_train, y_train)\n",
    "sgdr.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the value of default measurement of SGDRegression on test is:  0.899968732868\n",
      "The value of default measurement of SGDRegression on train is 0.93700324356\n"
     ]
    }
   ],
   "source": [
    "# 使用SGDR自带的模型评估模块，并输出评估结果\n",
    "# 测试集\n",
    "print('the value of default measurement of SGDRegression on test is: ', sgdr.score(X_test, y_test))\n",
    "\n",
    "# 训练集\n",
    "print('The value of default measurement of SGDRegression on train is', sgdr.score(X_train, y_train))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAH2VJREFUeJzt3Xl4VPX1+PH3STIJE7YAskgAWURU\nRIpSXHDBrYIixWJRC7Xap3Vp+9WKYqX6A2zdKopY61K3toqWomIqFURw+2ItFTAoIuJPsVSCSBAC\ngSRkO98/ZiYMYZY7ydzcycx5PU8eMnf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jXGMJxhjjGkswxhjXWIIxxrjm/wAUANdvsRd7eQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a19cfdc18>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "lr_y_predict = sgdr.predict(X_test)\n",
    "# 观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_test, lr_y_predict)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True Price')\n",
    "plt.ylabel('Predicted Price')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 正则化的线性回归（L2正则 --> 岭回归）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 岭回归/L2正则\n",
    "from sklearn.linear_model import RidgeCV\n",
    "alphas = [0.01, 0.1, 1, 10, 20, 40, 80,100]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RidgeCV(alphas=[0.01, 0.1, 1, 10, 20, 40, 80, 100], cv=None,\n",
       "    fit_intercept=True, gcv_mode=None, normalize=False, scoring=None,\n",
       "    store_cv_values=True)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reg = RidgeCV(alphas=alphas, store_cv_values=True)\n",
    "reg.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEKCAYAAADjDHn2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wL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6OgkJGgnoWIiETSALeIiERSWIiISCSFhYiIRFJYiIhIJIWFiIhEUliIiEik/w9s6UoN\n52F36gAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a1af34908>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is:  20.0\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[  2.14497237e-02,   6.60044263e-02,   1.93938331e-02,\n",
       "         -5.47839960e-03,  -2.33661891e-03,   8.04443338e-03,\n",
       "          1.96187499e-02,   1.41205619e-03,   2.43380058e-02,\n",
       "          1.57830373e-01,   2.67425238e-02,   5.06827915e-02,\n",
       "         -2.13419450e-03,  -4.38060753e-02,  -3.80621115e-03,\n",
       "          1.82766813e-03,   6.92067334e-02,   9.59498169e-03,\n",
       "          5.44605998e-02,   1.12808798e-02,  -1.40922658e-02,\n",
       "         -4.21581666e-02,   6.09844623e-03,   1.43469615e-02,\n",
       "          4.27465590e-02,  -3.05410918e-02,  -6.83223730e-03,\n",
       "          4.57835915e-03,  -1.02573308e-02,  -8.35455406e-03,\n",
       "         -1.61289066e-03,   3.06842148e-02,  -5.56913655e-02,\n",
       "         -4.32300231e-02,   2.12401974e-03,   4.33364680e-02,\n",
       "          5.61270276e-02,   2.14158260e-02,  -7.11500954e-04,\n",
       "         -4.63991057e-03,  -1.77559540e-02,  -3.56837980e-02,\n",
       "          5.73378293e-02,   1.25011182e-02,  -2.86079260e-03,\n",
       "          2.28111903e-02,   1.58842597e-02,  -8.76908247e-03,\n",
       "          9.11608540e-03,   2.53230321e-02,  -9.13727425e-03,\n",
       "         -7.81990622e-02,  -2.03161774e-02,   1.08821634e-02,\n",
       "          6.37742289e-02,  -3.03589252e-02,   4.98755173e-02,\n",
       "          1.98578518e-02,   2.14158260e-02,   5.90987969e-02,\n",
       "          9.18396548e-02,   6.75857253e-04,   6.29582549e-03,\n",
       "          5.29792037e-03,   2.08167719e-02,  -6.45857602e-03,\n",
       "          3.65863905e-02,   5.73952089e-02,   1.42744532e-01,\n",
       "          1.06086728e-02,   1.82334230e-02,   7.11296155e-02,\n",
       "          1.92919361e-02,   8.41487820e-03,   6.66241426e-02,\n",
       "          2.57209939e-02,   1.09118310e-02,   1.66138672e-02,\n",
       "         -5.37809889e-03,   4.79251913e-02,   5.96368996e-02,\n",
       "         -2.77420130e-02,   5.11470975e-02,   1.28725830e-02,\n",
       "         -2.39073107e-02,   3.79189619e-02,   7.95179685e-03,\n",
       "         -5.33861812e-02,   2.70810111e-02,   2.72013090e-02,\n",
       "         -1.63449507e-02,  -2.13419450e-03,  -2.13419450e-03,\n",
       "         -2.13419450e-03,   1.35435979e-02,  -9.03492653e-02,\n",
       "          4.07954880e-02,   9.22909932e-02,  -1.27390095e-02,\n",
       "         -1.39858481e-02,  -5.17363790e-02,  -1.38297566e-02,\n",
       "          0.00000000e+00,  -1.84714792e-02,   1.84714792e-02,\n",
       "          0.00000000e+00,   8.95621620e-04,  -4.18652220e-02,\n",
       "          7.65758651e-02,  -1.22928579e-02,  -1.29066053e-02,\n",
       "         -4.44766786e-02,  -1.51356773e-03,   8.13928876e-03,\n",
       "          2.74441561e-02,   0.00000000e+00,  -3.07109755e-03,\n",
       "          6.71370376e-03,   1.24668932e-02,   0.00000000e+00,\n",
       "         -6.60856475e-03,  -8.60372098e-03,   0.00000000e+00,\n",
       "         -8.97213688e-04,   0.00000000e+00,   1.17485294e-02,\n",
       "          8.64649535e-03,   3.73306255e-04,   8.36511909e-03,\n",
       "         -3.04980663e-02,   1.36461620e-03,  -9.92775788e-03,\n",
       "         -3.33207289e-03,  -1.38663879e-02,   8.49713983e-02,\n",
       "         -5.40832807e-03,   2.59023158e-02,  -2.71495691e-02,\n",
       "          2.72796391e-03,   8.97197775e-03,  -1.30314905e-02,\n",
       "          2.74665293e-03,   2.94321250e-02,  -3.15095018e-02,\n",
       "         -7.44040208e-02,   2.38766951e-02,   0.00000000e+00,\n",
       "         -1.91412660e-02,  -4.07746436e-03,   4.61283535e-03,\n",
       "         -9.64417177e-03,  -5.40832807e-03,   4.74216406e-02,\n",
       "         -2.91454434e-02,   1.29799574e-02,  -2.24394079e-03,\n",
       "         -7.99060304e-03,  -4.75613291e-02,  -5.50388034e-03,\n",
       "         -7.21502251e-03,  -1.52326558e-04,   5.43473618e-02,\n",
       "          1.87219808e-02,   0.00000000e+00,  -6.85306294e-04,\n",
       "         -8.16301710e-03,   2.40523412e-02,  -3.18100995e-02,\n",
       "          1.66060817e-02,   0.00000000e+00,   2.55175262e-02,\n",
       "         -2.77061443e-02,   3.75473582e-02,   1.87188450e-02,\n",
       "         -1.22670802e-02,  -4.18105050e-02,   0.00000000e+00,\n",
       "          2.39080966e-02,  -1.27373610e-02,  -2.43085449e-02,\n",
       "          1.31378093e-02,   0.00000000e+00,  -6.09248967e-02,\n",
       "          7.56288090e-04,  -1.83045987e-02,   6.16240294e-02,\n",
       "          1.21247908e-02,   1.74617482e-02,  -1.27373610e-02,\n",
       "          0.00000000e+00,   0.00000000e+00,   4.59360016e-02,\n",
       "         -4.55109156e-02,  -1.15504740e-03,  -1.01833120e-02,\n",
       "          1.09132735e-02,   0.00000000e+00,   5.41646185e-03,\n",
       "          3.08633180e-03,  -2.08420525e-02,  -3.30281471e-02,\n",
       "          2.56866014e-02,   4.96701616e-02,  -4.40784066e-02,\n",
       "          1.40890495e-02,   0.00000000e+00,   5.39157990e-03,\n",
       "          7.68939296e-02,  -6.30590876e-02,  -1.92264219e-02,\n",
       "          0.00000000e+00,  -6.51514318e-03,   7.92428247e-02,\n",
       "         -4.24341447e-02,  -1.44487688e-02,  -1.58447681e-02,\n",
       "          0.00000000e+00,   1.08062399e-02,   0.00000000e+00,\n",
       "         -6.61630470e-02,  -3.39722331e-02,  -1.27390095e-02,\n",
       "          2.41099318e-02,  -4.25577122e-02,   2.14684735e-02,\n",
       "         -1.18282251e-03,   4.46113894e-02,   3.42881721e-02,\n",
       "          6.00289882e-02,  -6.80439586e-03,   1.91511183e-03,\n",
       "         -1.98232386e-02,  -1.39858481e-02,   0.00000000e+00,\n",
       "         -7.69176381e-02,   7.16290183e-02,   6.93883551e-03,\n",
       "          3.26833282e-02,  -3.43335438e-02,   0.00000000e+00,\n",
       "         -5.44627016e-02,  -3.43799643e-02,   3.16637546e-03,\n",
       "          8.56762904e-02,   0.00000000e+00,  -8.60372098e-03,\n",
       "          6.26786169e-03,   1.19058295e-02,   2.03625332e-02,\n",
       "         -2.99325034e-02,   0.00000000e+00,   1.13709061e-02,\n",
       "         -7.07406274e-03,   1.05856165e-02,  -4.58172802e-02,\n",
       "          2.35061382e-02,   1.70902702e-02,  -8.79626184e-03,\n",
       "         -2.04802455e-02,   3.78559414e-02,  -8.12369012e-03,\n",
       "         -2.76274254e-02,   1.75100934e-02,   0.00000000e+00,\n",
       "         -5.10554664e-02,   1.47345858e-02,   2.46711446e-02,\n",
       "          7.23416956e-02,  -3.16454417e-02,  -8.24351810e-02,\n",
       "          1.70785518e-01,  -6.82613063e-02,  -8.68791177e-02,\n",
       "         -1.36043872e-02,  -9.93151790e-02,  -9.88863890e-02,\n",
       "         -5.75383440e-02,   3.23766781e-02,  -7.45800239e-02,\n",
       "         -5.73410603e-03,   2.23498786e-01,  -2.79613334e-02,\n",
       "         -7.53624866e-03,  -1.35643647e-02,  -4.95336504e-02,\n",
       "          8.16170307e-03,   2.00983196e-01,  -3.71256371e-02,\n",
       "          5.81028693e-02,   0.00000000e+00,  -4.54760592e-02,\n",
       "          2.65430684e-02,   5.80613751e-03,  -4.70187822e-03,\n",
       "         -4.08531447e-02,   2.42239639e-03,   5.62594798e-02,\n",
       "          0.00000000e+00,  -1.42972761e-02,  -4.37852722e-02,\n",
       "          2.22807148e-02,   3.35816626e-02,  -7.82176656e-03,\n",
       "          1.00419375e-02,   0.00000000e+00,  -4.44811572e-02,\n",
       "          1.15927137e-02,  -6.66845447e-03,  -2.99431579e-02,\n",
       "          5.93252574e-02,   1.01747986e-02,   0.00000000e+00,\n",
       "         -4.01631164e-02,   4.50218643e-02,   1.43185717e-02,\n",
       "          6.74006745e-03,   1.65352387e-02,   4.85283320e-03,\n",
       "          5.32110929e-02,  -1.99672761e-02,  -8.05492758e-02,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00,   0.00000000e+00,   0.00000000e+00,\n",
       "          0.00000000e+00]])"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_mean = np.mean(reg.cv_values_, axis=0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas), 1))\n",
    "plt.plot(np.log10(reg.alpha_)*np.ones(3), [0.1, 0.15, 0.20])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print('alpha is: ', reg.alpha_)\n",
    "reg.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of default measurement of RidgeRegression is 0.909282377876\n"
     ]
    }
   ],
   "source": [
    "# 使用LinearRegression模型自带的评估模块（r2_score），并输出评估结果\n",
    "print('The value of default measurement of RidgeRegression is', reg.score(X_test, y_test))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 正则化的线性回归（L1正则 --> Lasso）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/qi/anaconda3/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py:1094: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "LassoCV(alphas=[0.01, 0.1, 1, 10, 100], copy_X=True, cv=None, eps=0.001,\n",
       "    fit_intercept=True, max_iter=1000, n_alphas=100, n_jobs=1,\n",
       "    normalize=False, positive=False, precompute='auto', random_state=None,\n",
       "    selection='cyclic', tol=0.0001, verbose=False)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Lasso/L1正则\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "alphas = [0.01, 0.1, 1, 10, 100]\n",
    "\n",
    "lasso = LassoCV(alphas=alphas)\n",
    "lasso.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAH7RJREFUeJzt3Xl0VOed5vHvTztI7BKbFiRssI1t\nbLAscOw4Tuwk2J3g2PEChs4y6fjkZDLTPb1Mu0/mODPpP/p0MsuZdDvd7WRy0h1kCHa8YIfE8Rp3\nFgkEGAzG2BhQSWySALNIaP/NH1UUFVlCJdDVlaqezzk61PKW6tFFqqfqvlXvNXdHREQEICPsACIi\nMnqoFEREJE6lICIicSoFERGJUymIiEicSkFEROJUCiIiEqdSEBGROJWCiIjEZYUdYKgKCwu9vLw8\n7BgiImPKli1bWty9aLBxY64UysvLqaurCzuGiMiYYmb1yYzT7iM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JWCiIjEqRRERCROpSAiInEqBRERifv/Dbv4c6iE\nm8gAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a1b714d30>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is:  0.01\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([ 0.02452591,  0.04802438,  0.00913969, -0.00100968, -0.01429718,\n",
       "        0.        ,  0.        ,  0.        ,  0.        ,  0.12719   ,\n",
       "        0.02110642,  0.03902017,  0.0016329 , -0.00572803,  0.        ,\n",
       "       -0.        ,  0.05402164, -0.        ,  0.09776698, -0.        ,\n",
       "       -0.        , -0.        ,  0.        ,  0.01490556,  0.        ,\n",
       "        0.        , -0.        ,  0.        ,  0.        , -0.00239768,\n",
       "        0.        ,  0.01816272, -0.03788667, -0.05066709,  0.02761833,\n",
       "        0.04093829,  0.04448334,  0.04359429,  0.01169637,  0.        ,\n",
       "        0.        ,  0.        ,  0.01525044,  0.        ,  0.        ,\n",
       "        0.01556615,  0.01592738, -0.        ,  0.00479801,  0.02979912,\n",
       "       -0.        , -0.        , -0.00329419,  0.00548192,  0.10480596,\n",
       "        0.        ,  0.        ,  0.        ,  0.00724558,  0.0112219 ,\n",
       "        0.        ,  0.        ,  0.        ,  0.        ,  0.0002856 ,\n",
       "       -0.        ,  0.08106782,  0.0776975 ,  0.17640661,  0.        ,\n",
       "        0.        ,  0.1272878 ,  0.07403747,  0.        ,  0.        ,\n",
       "        0.        ,  0.        ,  0.01145067,  0.        ,  0.        ,\n",
       "        0.08944589,  0.        ,  0.        ,  0.        , -0.        ,\n",
       "        0.        ,  0.01789608,  0.        ,  0.        ,  0.0260235 ,\n",
       "        0.        ,  0.04931922,  0.        ,  0.        ,  0.        ,\n",
       "       -0.        ,  0.01680548,  0.03536323, -0.        , -0.        ,\n",
       "       -0.        , -0.        ,  0.        , -0.        ,  0.        ,\n",
       "        0.        , -0.        , -0.        ,  0.01667656, -0.        ,\n",
       "       -0.        , -0.        , -0.        ,  0.        ,  0.        ,\n",
       "        0.        , -0.        , -0.        ,  0.        ,  0.        ,\n",
       "       -0.        , -0.        ,  0.        , -0.        ,  0.        ,\n",
       "        0.        ,  0.        , -0.        ,  0.        , -0.        ,\n",
       "        0.        , -0.        ,  0.        , -0.        ,  0.        ,\n",
       "       -0.        ,  0.        , -0.        ,  0.        ,  0.        ,\n",
       "       -0.        , -0.        ,  0.        , -0.        , -0.        ,\n",
       "        0.        ,  0.        , -0.        ,  0.        , -0.        ,\n",
       "        0.        , -0.        ,  0.        , -0.        ,  0.        ,\n",
       "        0.        , -0.        , -0.        ,  0.        , -0.        ,\n",
       "       -0.        ,  0.        ,  0.        ,  0.        , -0.        ,\n",
       "       -0.        , -0.        , -0.        ,  0.        ,  0.        ,\n",
       "        0.        , -0.03011716,  0.        ,  0.        , -0.        ,\n",
       "       -0.        ,  0.        ,  0.00671281, -0.        , -0.        ,\n",
       "       -0.        ,  0.        , -0.        , -0.        , -0.        ,\n",
       "        0.        , -0.        ,  0.        , -0.        ,  0.        ,\n",
       "        0.        ,  0.        , -0.        , -0.        , -0.        ,\n",
       "        0.        ,  0.        ,  0.        ,  0.        , -0.        ,\n",
       "       -0.        , -0.        ,  0.        , -0.        , -0.        ,\n",
       "        0.        ,  0.        ,  0.        , -0.        , -0.        ,\n",
       "        0.        , -0.        ,  0.        , -0.        , -0.        ,\n",
       "       -0.        ,  0.        ,  0.        ,  0.        , -0.        ,\n",
       "       -0.        , -0.        ,  0.        , -0.        ,  0.        ,\n",
       "        0.        ,  0.        ,  0.        ,  0.        , -0.        ,\n",
       "        0.        , -0.        , -0.        ,  0.        , -0.        ,\n",
       "        0.        ,  0.        ,  0.        , -0.        ,  0.        ,\n",
       "       -0.        , -0.01829958,  0.        ,  0.        ,  0.        ,\n",
       "       -0.        ,  0.        ,  0.        , -0.        , -0.        ,\n",
       "        0.        ,  0.        , -0.        ,  0.        , -0.        ,\n",
       "        0.        ,  0.        ,  0.        , -0.        ,  0.        ,\n",
       "       -0.        , -0.        ,  0.        ,  0.        , -0.        ,\n",
       "        0.        , -0.        ,  0.        , -0.        , -0.        ,\n",
       "        0.0047752 , -0.        , -0.        , -0.        , -0.        ,\n",
       "       -0.        , -0.        ,  0.        , -0.        , -0.        ,\n",
       "        0.15859131, -0.        ,  0.        ,  0.        , -0.        ,\n",
       "        0.        ,  0.        , -0.        ,  0.        ,  0.        ,\n",
       "       -0.        ,  0.        ,  0.        , -0.        , -0.        ,\n",
       "       -0.        ,  0.        ,  0.        , -0.        , -0.02431866,\n",
       "        0.        ,  0.00309884, -0.        , -0.        ,  0.        ,\n",
       "       -0.        ,  0.        , -0.        , -0.        ,  0.        ,\n",
       "        0.        ,  0.        , -0.        ,  0.        ,  0.        ,\n",
       "       -0.        ,  0.        ,  0.        ,  0.        , -0.        ,\n",
       "       -0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "        0.        ,  0.        ,  0.        ])"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis=1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses)\n",
    "plt.xlabel('log(alphas)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print('alpha is: ', lasso.alpha_)\n",
    "lasso.coef_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "对比岭回归、最小二乘回归，可以明显看到Lasso回归能够使回归系数矩阵稀疏化的特点。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 在本任务中，最佳alpha为参数grid的最左端，继续检查比当前更小的alpha是否会更好"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of default measurement of Lasso Regression on test is 0.891042777313\n",
      "The value of default measurement of Lasso Regression on train is 0.895712017952\n"
     ]
    }
   ],
   "source": [
    "# 使用LinearRegression模型自带的评估模块（r2_score），并输出评估结果\n",
    "print('The value of default measurement of Lasso Regression on test is', lasso.score(X_test, y_test))\n",
    "print('The value of default measurement of Lasso Regression on train is', lasso.score(X_train, y_train))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 模型选择"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 综合三者在训练集和验证集上评估结果, 可以看出Lasso回归模型表现更好. 试用Lasso回归对测试数据集进行预测.\n",
    "data_test = pd.read_csv(dpath + \"AmesHouse_FE_test.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X_predict = data_test.drop(['Id'], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": true,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "y_predict = lasso.predict(X_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y_predict = ss_y.inverse_transform(y_predict, copy=None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "result = pd.DataFrame({'Id':data_test['Id'], 'SalePricePredict':y_predict})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "result.to_csv('AmesHousePricesPredictResult.csv',index=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
